#ifndef CELL_H
#define CELL_H

#include <QObject>
#include <QRect>
#include <QLine>
#include <QList>
#include "Element.h"

class QPainter;
class Dot;
class Line;

class Cell :public  QRect, public Element
{
public:    
    Cell(QPoint topleft, QSize size,uint nRow,uint nCol);

public:
    QLine leftLine();
    QLine topLine();
    QLine rightLine();
    QLine bottomLine();

    bool addLine(Line *pLine);
    bool removeLine(Line *pLine);
    bool isLineAdded(Line *pLine);    
    bool isLineAdded(QLine line);
    int lineAddedCount();
    bool addDot(Dot *pDot);
    bool removeDot(Dot *pDot);
    bool isDotAdded(Dot *pDot);
    bool isDotAdded(QPoint pos);
    int dotAddedCount();
    bool isCompleted();
    bool isAdjacent_Straight(Cell *pCell);
    Game::Player owner();

    bool nearToMe(QPoint pos);
    QRect rect();

    uint row();
    uint column();
    bool isACorner(Dot *pDot);
    bool isACorner(QPoint pos);
    bool isASide(Line *pLine);
    bool isASide(QLine line);

    void draw(QPainter *pDC);
    void drawOwner(QPainter *pDC);
    bool isSame(Element *pElem, bool bByValue = true);
    bool isSame(QRect rect);
    QList<QLine> getSidesThatNotAddYet();
    QLine commonSide(Cell *pCell);
    QList<QLine> sides();
    bool isWinableNow();

private:


private:
    Game::Player mOwner;
    QList<Line*> mLines;
    QList<Dot*> mDots;
    uint mnRow,mnCol;
};

#endif // CELL_H
